package cn.tianya.irock.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Regex {

	private static final Pattern GRAB_SP_CHARS = Pattern.compile("([\\\\*+\\[\\](){}\\$.?\\^|])");
	
	public static String escape(String str) {
		Matcher match = GRAB_SP_CHARS.matcher(str);
		return match.replaceAll("\\\\$1");
	}
	
	public static String escRegEx(String str) {
		return str.replaceAll("([\\\\*+\\[\\](){}\\$.?\\^|])", "\\\\$1");
	}
	
	public static String replace(String content, String pattern, String replacement) {
		return content.replaceAll(pattern, replacement);
	}
}
